import psycopg2
# 连接到 PostgreSQL 数据库
conn = psycopg2.connect(
    dbname="nmg_info",
    user="postgres ",
    password="此处填写数据库密码",
    host="localhost",
    port="5432"
)
cursor = conn.cursor()
# 插入数据
cursor.execute('''
INSERT INTO population.population_info 
(region_id, year, total_population)
VALUES (%s, %s, %s)
''', (101, 2023, 2404.9))
# 提交事务
conn.commit()
# 关闭连接
conn.close()
print('数据插入成功！')
